package com.dnw.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.dnw.shyfunny.R;
import com.dnw.util.GlideUtils;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @author ChayChan
 * @description: 频道的adapter
 * @date 2017/6/16  9:45
 */

public class ProgramImagesAdapter extends BaseAdapter {
    private Context  mContext;
    private String[] mImages;

    public ProgramImagesAdapter(Context context, String[] images) {
        mContext = context;
        mImages = images;
    }

    @Override
    public int getCount() {
        return mImages.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        convertView = LayoutInflater.from(mContext).inflate(R.layout.item_program_image, null);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
        final String image = mImages[position];
        GlideUtils.load(mContext, image, holder.ivImage, R.drawable.ic_launcher);//设置缩略图
        return convertView;
    }

    static class ViewHolder {
        @Bind(R.id.iv_image)
        ImageView ivImage;

        public ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
